public class VyattaCommands extends Thread
{
		public VyattaCommands(VyattaTerminalOutput vteriminal)
		{
			try
			{
				Thread.sleep(3000);
				vteriminal.getOutput().write("sudo su -\n".getBytes()); 
			    vteriminal.getOutput().flush(); 
			    Thread.sleep(3000);
			    System.out.println("buffer="+vteriminal.getStrbuff()); 
			    System.out.println((vteriminal.getStrbuff()).length());
			    if(vteriminal.getStrbuff().toString().contains("~$")) 
			    { 
			    	System.out.println("Successfully entered into Root mode"); 
			    	vteriminal.getOutput().write("configure\n".getBytes()); 
			    	vteriminal.getOutput().flush(); 
			     	Thread.sleep(2000);
			     	if(vteriminal.getStrbuff().toString().contains("~#")) 
			     	{
			     		System.out.println("Successfully entered into Configure mode"); 
			     		vteriminal.getOutput().write("set service snmp community public authorization ro\n".getBytes()); 
			  	    	vteriminal.getOutput().flush(); 
			         	Thread.sleep(2000);
			         	vteriminal.getOutput().write("set service snmp community public client 192.168.1.38\n".getBytes()); 
	          	    	vteriminal.getOutput().flush(); 
	                 	Thread.sleep(2000);
	                 	if(vteriminal.getStrbuff().toString().contains("exists"))
	                 	{
	                 		vteriminal.getOutput().write("delete service snmp\n".getBytes()); 
	              	    	vteriminal.getOutput().flush(); 
	                     	Thread.sleep(2000);
	                 	}
		             	System.out.println("loginbuffer="+vteriminal.getStrbuff()); 
			        	vteriminal.getOutput().write("commit\n".getBytes()); 
			          	vteriminal.getOutput().flush(); 
			           	Thread.sleep(2000);
			           	System.out.println("loginbuffer="+vteriminal.getStrbuff());	              	
			          	vteriminal.getOutput().write("save\n".getBytes()); 
			        	vteriminal.getOutput().flush(); 
			         	Thread.sleep(2000);
			         	System.out.println("loginbuffer="+vteriminal.getStrbuff());	            	      	  	  
			  	    	vteriminal.getOutput().write("exit\n".getBytes()); 
			        	vteriminal.getOutput().flush(); 
			         	Thread.sleep(2000);
			         	System.out.println("loginbuffer="+vteriminal.getStrbuff());	  
			         	vteriminal.getOutput().flush(); 
			     	}
			    }
			}
		    catch (Exception e) {
				e.printStackTrace();
			}
  	 
		}
}
